package day03;

public class 晚自习 {
    public static void main(String[] args) {
        /*
        //算术
        System.out.println(5%2);//1
        System.out.println(8%2);//2
        System.out.println(2%8);//2
        //单独用，自增
        int a=5,b=5;
        a++;
        ++a;
        System.out.println(a);//6
        System.out.println(b);//6
        //单独用，自减
        int a1=5,b1=5;
        a--;
        --a;
        System.out.println(a1);//4
        System.out.println(b1);//4
        //被使用，自增
        int a2=5,b2=5;
        int c2=a2++;
        int d2=++b2;
        System.out.println(a2);//6
        System.out.println(b2);//6
        System.out.println(c2);//5
        System.out.println(d2);//6
        //被使用，自减
        int a3=5,b3=5;
        int c3=a3--;
        int d3=--b3;
        System.out.println(a3);//4
        System.out.println(b3);//4
        System.out.println(c3);//5
        System.out.println(d3);//4
         */

        /*
        //关系
        int a3=5,b3=10,c3=5;
        boolean b4=b>a;
        System.out.println(b3);//true
        System.out.println(c3<b3);//true
        System.out.println(a3>=c3);//true
        System.out.println(b3<=a3);//false
        System.out.println(b3==c3);//false
        System.out.println(a3!=c3);//false
        System.out.println(a3+c3>10);//false
        System.out.println(b3%2==0);//true
        System.out.println(c3++>5);//false
        System.out.println(c3++>5);//true
         */

        /*
        //逻辑
        int a=5,b=10,c=5;
        //演示&&
        boolean b1 = b>=a && b<c;
        System.out.println(b1);
        System.out.println(b<=c && b>a);//false
        System.out.println(a==b && c>b);//false
        System.out.println(b!=c && a<b);//true
        //演示||
        System.out.println(b>=a && b<c);//true
        System.out.println(b<=c && b>a);//true
        System.out.println(b!=c && a<b);//true
        System.out.println(a==b && c>b);//false
        //演示!
        boolean b2 = !(a<b);
        System.out.println(b2);//!true=false
        System.out.println(!(a>b));//!false=true
        //演示&&的短路
        int a1=5,b1=10,c1=5;
        boolean b2=a>b && c1++>2;
        System.out.println(b2);//false
        System.out.println(c1);//5
        //演示||的短路
        boolean b3=a<b ||c++>2;
        System.out.println(b3);//true
        System.out.println(c);//5
         */

        /*
        //赋值
        int a=5;
        a += 10;//相当于a=(int)(a+10)
        System.out.println(a);//15
        a *= 2;
        System.out.println(a);//15*2=30
        a /= 6;
        System.out.println(a);//30/6=5

        short s =5;
        s = s+10;//编译错误，需要强转，改为：s=(short)(s+10）
        s +=10;//赋值运算符具有强转功能
         */

        /*
        //字符串连接
        int age = 38;
        System.out.println("age="); //age=
        System.out.println(age);    //38
        System.out.println("age="+age); //age=38
        System.out.println("我的年龄是"+age); //我的年龄是38
        System.out.println("我今年"+age+"岁了"); //我今年38岁了

        String name = "WKJ";
        System.out.println("name="+name); //name=WKJ
        System.out.println("大家好，我叫"+name); //大家好，我叫WKJ
        System.out.println("大家好，我叫"+name+"，今年"+age+"岁了"); //大家好，我叫WKJ，今年38岁了

        //演示同化作用
        System.out.println(10+20+""+30); //3030---------String
        System.out.println(""+10+20+30); //102030-------String
        System.out.println(10+20+30+""); //60-----------String
         */

        /*
        //条件/三目
        int num = 5;
        int flag = num>0?1:-1;
        System.out.println(flag);//1

        int a=8,b=5;
        int max = a>b?a:b;
        System.out.println("max"+max);//max8
         */

        //if
        //满500打8折：
        double price = 300.0;
        if(price>=500){
            price *= 0.8;
        }
        System.out.println(price);
        //判断成绩是否合法
        int score = 555;
        if(score>=0 && score<=100){
            System.out.println("成绩合法");
        }
        System.out.println("继续执行");

        //if...else
        //满500打8折，不满500打9折
        double price1 = 300.0;
        if(price1>=500){
            price1 *= 0.8;
        }else{
            price1 *= 0.9;
        }
        System.out.println("最终消费金额为"+price1);

        //判断成绩合法还是不合法
        int score1 = 95;
        if(score1>=0 && score1<=100){
            System.out.println(score1+"成绩合法");
        }else{
            System.out.println(score1+"成绩不合法");
        }

        //if...else if
        //满2000打5折，满1000不满2000打7折，满500不满1000打8折，不满500打9折
        double price2 = 6000.0;
        if(price>=2000.0){
            price *= 0.5;
        }else if(price>=1000){
            price *= 0.7;
        }else if(price>=500){
            price *= 0.8;
        }else{
            price *= 0.9;
        }
        System.out.println("最终消费金额为"+price);


        //!、++、--，优先级高

    }
}
